package ljt.music.module.blank;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;

import com.ljq.mvpframework.presenter.BaseMvpPresenter;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * @author jiangtao
 * @date 2017/12/21
 */

public class BlankFragmentPresenter extends BaseMvpPresenter<BlankFragmentView> {
    private BlankFragmentModel mBlankFragmentModel;

    public BlankFragmentPresenter() {
        this.mBlankFragmentModel = new BlankFragmentModel();
    }

    public void request(String maxBehotTime) {
        Log.e("perfect-mvp", "点击事件 P ");
        if (getMvpView() != null) {
            getMvpView().requestLoading();
        }
        mBlankFragmentModel.request(maxBehotTime, new Callback<String>() {
            @Override
            public void onResponse(Call<String> call, Response<String> response) {

            }

            @Override
            public void onFailure(Call<String> call, Throwable t) {

            }
        });
    }

    @Override
    public void onCreatePresenter(@Nullable Bundle savedState) {
        super.onCreatePresenter(savedState);
        if (savedState != null) {
            Log.e("perfect-mvp", "MainActivityPresenter  onCreatePresenter 测试  = " + savedState.getString("test2"));
        }
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        Log.e("perfect-mvp", "MainActivityPresenter  onSaveInstanceState 测试 ");
        outState.putString("test2", "test_save2");
    }

    @Override
    public void onDestroyPresenter() {
        super.onDestroyPresenter();
    }

    public void interruptHttp() {
        mBlankFragmentModel.interruptHttp();
    }

    public void doRefresh() {

    }
}
